<template>
  <basic-container>
    <avue-crud :option="option"
               :data="data"
               ref="crud"
               v-model="form"
               :table-loading="loading"
               :permission="permissionList"
               @row-update="rowUpdate"
               @row-save="rowSave"
               :page="page"
               @refresh-change="refreshChange"
               @search-change="searchChange"
               @search-reset="searchReset"
               @selection-change="selectionChange"
               @current-change="currentChange"
               @size-change="sizeChange"
               @on-load="onLoad">
      <!-- 自定义添加搜索条件  按日期搜索  -->
      <template slot="search">
        <el-col  :span="12">
          <el-form-item label="提交申请时间"label-width="100px" style="display: inline-block;width: 50%;">
            <el-date-picker placeholder="开始时间" value-format="yyyy-MM-dd HH:mm:ss" v-model="beginAddTime" type="datetime" size="small">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="至"　label-width="40px" style="display: inline-block;width: 50%;">
            <el-date-picker placeholder="结束日期" @change="getTime" value-format="yyyy-MM-dd HH:mm:ss" v-model="endAddTime" type="datetime" size="small">
            </el-date-picker>
          </el-form-item>
        </el-col>

      </template>

      <template slot="searchMenu">
        <el-button type="primary" size="mini" @click="outExcelDialog">导出</el-button>
      </template>

      <template slot="searchMenu">
        <el-upload action="/account/withDrawRecord/inExcel"
                   name="file"
                   :show-file-list="false"
                   ref="upload"
                   :before-upload="beforeUpload"
                   :on-success="handleSuccess"
                   :on-error="handleError"
                   :accept="aceeptExt"
                   :headers="myHeaders">
          <el-button style="margin-left: 10px" type="primary" size="mini">导入</el-button>
          <!--          ？ @click="submitUpload"-->
        </el-upload>
      </template>
      <template slot-scope="{row}"
                slot="menu">
        <el-button type="primary"
                   size="small"
                   plain
                   v-if="row.status==0"
                   @click.stop="getDetail(row)" v-has="'/mall-cloud-account/withDrawRecord/detail'">处理</el-button>
        <el-button type="primary"
                   size="small"
                   plain
                   v-if="row.payStatus==1 && row.status==3"
                   @click.stop="goPayDetail(row)" v-has="'/mall-cloud-account/withDrawRecord/detail'">打款</el-button>

        <el-button type="primary"
                   size="small"
                   plain
                   v-if="row.status==2 || row.status==4"
                   @click.stop="getDetail(row)" v-has="'/mall-cloud-account/withDrawRecord/detail'">查看</el-button>
      </template>
    </avue-crud>

    <el-col class="btnRow" :span="8">
      <span class="allAmount">总申请提现金额：{{allAmount}}</span>
    </el-col>

    <el-drawer title="处理" :visible.sync="dialogTableVisible" size="70%">
      <avue-form ref="obj"
                 v-model="obj"
                 :option="optionView">
        <template slot="menuForm">
          <el-button type="primary" size="mini"  v-if="obj.newStatus==0" :loading="loadBtn" @click="commitCheck(obj.id,obj.status,obj.refuseRemark)" v-has="'/mall-cloud-account/withDrawRecord/withDrawStatusOthers'">提 交</el-button>
          <el-button size="mini" @click="cancel(obj.newStatus)">取 消</el-button>
        </template>
      </avue-form>
    </el-drawer>

    <el-drawer title="打款" :visible.sync="goPayDialogTableVisible" size="70%" :wrapperClosable="false"
               :show-close="false">
      <avue-form ref="payCommit"
                 v-model="payObj"
                 :option="alreadyPayOptionView">
        <template slot="menuForm">
          <el-button type="primary" size="mini"  v-if="payObj.newPayStatus==1" :loading="goPayLoadBtn" @click="commitGoPayCheck(payObj.id,payObj.payStatus,payObj.actualAmount,payObj.payRemark)" v-has="'/mall-cloud-account/withDrawRecord/withDrawCarryOut'">提 交</el-button>
          <el-button size="mini" @click="cancelGoPayCheck(payObj.newPayStatus)">取 消</el-button>
        </template>
      </avue-form>
    </el-drawer>

    <el-dialog title="导出" :visible.sync="dialogVisibleOutExcel" width="40%" @close="closeOutExcel">
      <el-button type="primary" @click="outExcel()">仅导出勾选</el-button>
      <el-button type="primary" @click="outAllExcel()">仅导出全部</el-button>
      <el-button type="primary" @click="outExcelChangeStatus()">导出并把状态改为处理中</el-button>
    </el-dialog>

  </basic-container>
</template>

<script>
  import {
    getList,
    getWithDrawRecordDetail,
    withDrawCarryOut,
    withDrawStatusOthers,
    selectAndUpdate
  } from "@/api/account/userAccount/adminWithDrawRecord";
  import {
    testActualAmount
  } from '@/util/util';
  import { mapGetters } from "vuex";
  import {getToken} from '@/util/store';
  var Dict = JSON.parse(localStorage.getItem('mall-dictionary')).content;
  var CHECKDIC = [
    {
      label: '审核通过',
      value: 1,
    }, {
      label: '审核拒绝',
      value: 2,
    }]
  var DEAL = [
    {
      label: '处理',
      value: 3,
    }]
  var PAYCHECKDIC = [{
    label: '打款',
    value: 0,
  }]
  export default {
    data () {
      return {
        aceeptExt:".xls,.xlsx",      //上传文件可接受的扩展名
        idList: [],
        allAmount:0,
        myHeaders: { Authorization: getToken() },
        dialogVisibleOutExcel:false,
        beginAddTime: '',
        endAddTime: '',
        loadBtn:false,
        goPayLoadBtn:false,
        deleteList: [], //全选的删除
        form: {},
        obj:{},
        payObj:{},
        arroyAllDict:{},
        query: {},
        loading: true,
        rolesTree: [],
        rolesKeys: [],
        box: false,
        dialogTableVisible: false,
        goPayDialogTableVisible: false,
        page: {
          pageSize: 10,
          currentPage: 1,
          total: 0
        },
        option: {
          //title:'提现申请记录',
          align: 'center',
          size: 'mini',
          tip: true,
          border: true,
          index: false,
          selection: true,
          viewBtn: false,
          delBtn: false,
          addBtn: false,
          editBtn: false,
          rowKey: 'id',
          height: 'auto',
          // calcHeight: 380,
          menuWidth: 150,
          searchMenuSpan:6,
          column: [
            {
              label: "团长类型",
              prop: "groupType",
              dicData: Dict.groupLeaderTypeEnum,
              search: true,
              type: 'select',
            },
            {
              label: "团长姓名",
              prop: "groupName",
              search: true,
            },
            {
              label: "申请提现金额",
              prop: "amount",
            },
            {
              label: "提现账户",
              prop: "account",
            },
            {
              label: "提交申请的时间",
              prop: "addTime",
              width: 160
            },
            {
              label: "区域",
              prop: "groupProvince",
            },
            {
              label: "城市",
              prop: "groupCity",
            },
            {
              label: "项目/详细地址",
              prop: "groupAreaInfo",
            },
            {
              label: "手机号",
              prop: "groupMobile",
              search: true,
            },
            {
              label: "状态",
              prop: "status",
              type: 'select',
              dicData: Dict.withDrawShowStatusEnum,
              search: true,
            }
          ]
        },
        optionView: {
          size: "samll",
          mock: false,
          submitBtn: false,
          emptyBtn: false,
          menuPostion: 'center',
          labelWidth: '100',
          group:[
            {
              label: '基本信息',
              prop: 'group0',
              column: [
                {
                  label: "账户名称",
                  prop: "uaAccountName",
                  fixed: true,
                  disabled:true,
                  display:true,
                },
                {
                  label: "提现账户",
                  prop: "account",
                  fixed: true,
                  disabled:true,
                  display:true,
                },
                {
                  label: "提现金额",
                  prop: "amount",
                  fixed: true,
                  disabled:true,
                  display:true,
                },
                {
                  label: "提现渠道",
                  prop: "payWay",
                  fixed: true,
                  type:'select',
                  disabled:true,
                  dicData: Dict.payWayEnum,
                  display:true,
                },
                {
                  label: "申请原因",
                  prop: "remark",
                  fixed: true,
                  disabled:true,
                  type: 'textarea',
                  display:true,
                },
                {
                  label: "审核操作人",
                  prop: "operationUserName",
                  fixed: true,
                  disabled:true,
                  display:true,
                },
                {
                  label: "审核操作时间",
                  prop: "operationTime",
                  fixed: true,
                  disabled:true,
                  display:true,
                },
                {
                  label: "拒绝原因",
                  prop: "refuseRemark",
                  type: 'textarea',
                  disabled:true,
                  fixed: true,
                  value:false,
                  display:true,
                },
                {
                  label: "打款状态",
                  prop: "payStatus",
                  fixed: true,
                  type:'select',
                  dicData: Dict.payStatusEnum,
                  disabled:true,
                  display:true,
                },
                {
                  label: "打款人",
                  prop: "payManName",
                  fixed: true,
                  disabled:true,
                  display:true,
                },
                {
                  label: "打款时间",
                  prop: "payTime",
                  fixed: true,
                  disabled:true,
                  display:true,
                },
                {
                  label: "实际打款金额",
                  prop: "actualAmount",
                  placeholder:"实际打款金额",
                  fixed: true,
                  disabled:true,
                  display:true,
                },
                {
                  label: "打款描述",
                  prop: "payRemark",
                  type: 'textarea',
                  disabled:true,
                  fixed: true,
                  value:false,
                  display:true,
                }
              ]
            },
            {
              label: '处理',
              prop: 'group1',
              column: [
                {
                  label: "处理",
                  prop: "status",
                  type: 'radio',
                  row: true,
                  display:true,
                  dicData: DEAL,
                  rules: [{
                    required: true,
                    message: "请选择处理选项",
                    trigger: "blur"
                  }],
                }
                // ,
                // {
                //     label: "拒绝原因",
                //     prop: "refuseRemark",
                //     type: 'textarea',
                //     display:true,
                //     fixed: true,
                //     value:false,
                //     rules: [{
                //         required: true,
                //         message: "请输入拒绝原因",
                //         trigger: "blur"
                //     }]
                // }
              ]
            }
          ],

        },
        alreadyPayOptionView: {
          size: "mini",
          mock: false,
          submitBtn: false,
          emptyBtn: false,
          menuPostion: 'center',
          labelWidth: '100',
          group:[
            {
              label: '基本信息',
              prop: 'group0',
              column: [
                {
                  placeholder:"账户名称",
                  label: "账户名称",
                  prop: "uaAccountName",
                  fixed: true,
                  disabled:true,
                  display:true,
                },
                {
                  placeholder:"提现账户",
                  label: "提现账户",
                  prop: "account",
                  fixed: true,
                  disabled:true,
                  display:true,
                },
                {
                  placeholder:"提现金额",
                  label: "提现金额",
                  prop: "amount",
                  fixed: true,
                  disabled:true,
                  display:true,
                },
                {
                  placeholder:"未选择",
                  label: "提现渠道",
                  prop: "payWay",
                  fixed: true,
                  type:'select',
                  disabled:true,
                  dicData: Dict.payWayEnum,
                  display:true,
                },
                {
                  placeholder:"申请原因",
                  label: "申请原因",
                  prop: "remark",
                  type: 'textarea',
                  disabled:true,
                  fixed: true,
                  value:false,
                  display:true,
                },
                {
                  placeholder:"打款人",
                  label: "打款人",
                  prop: "payManName",
                  fixed: true,
                  disabled:true,
                  display:true,
                },
                {
                  placeholder:"打款时间",
                  label: "打款时间",
                  prop: "payTime",
                  fixed: true,
                  disabled:true,
                  display:true,
                },
                {
                  placeholder:"打款描述",
                  label: "打款描述",
                  prop: "payRemark",
                  type: 'textarea',
                  disabled:true,
                  fixed: true,
                  value:false,
                  display:true,
                }
              ]
            },
            {
              label: '打款',
              prop: 'group1',
              column: [
                {
                  label: "打款",
                  prop: "payStatus",
                  type: 'radio',
                  row: true,
                  dicData: PAYCHECKDIC,
                  rules:[{
                    required:true,
                    message:'请勾选打款选项',
                    trigger: "blur"
                  }]
                },
                {
                  label: '实际打款金额',
                  prop: 'actualAmount',
                  type: 'input',
                  labelWidth: 120,
                  display:true,
                  maxlength: 11,
                  rules: [
                    {required: true, message: '请输入实际打款金额', trigger: 'blur'},
                    {required: true, trigger: 'blur', validator: testActualAmount }
                  ]
                },
                {
                  label: "打款描述",
                  prop: "payRemark",
                  type: 'textarea',
                  display:true,
                  fixed: true,
                  value:false,
                  placeholder:"打款描述",
                  maxlength: 100,
                }
              ]
            }
          ],

        },
        data: []
      };
    },
    watch:{
      'obj.status'(){
        if(this.obj.status == 2){
          this.optionView.group[1].column[1].display = true
        }
        // else{
        //     this.optionView.group[1].column[1].display = false
        //     this.obj.refuseRemark = ''
        // }
      },
      'payObj.newPayStatus'(){
        if(this.payObj.newPayStatus == 1){
          this.alreadyPayOptionView.group[1].column[1].display = true
          this.alreadyPayOptionView.group[1].column[2].display = true
        }
        else{
          this.alreadyPayOptionView.group[1].column[1].display = false
          this.alreadyPayOptionView.group[1].column[2].display = false
        }
      }
    },
    computed: {
      ...mapGetters(["permission", 'userInfo']),
      permissionList () {
        return {
          editBtn: this.vaildData(this.permission["/mall-cloud-account/withDrawRecord/editItem"], false)
        };
      },
    },
    methods: {
      getTime() {
        if (this.beginAddTime > this.endAddTime) {
          this.$message({
            type: "error",
            message: "结束时间不能小于开始时间"
          });
          this.endAddTime = ''
        }
      },

      rowSave (row, loading, done) {
        row.position = row.positionIds;
        row.deptName = row.$deptId;
        row.repassword = row.password;
        add(row).then(() => {
          loading();
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
        }, error => {
          done();
          console.log(error);
        });
      },
      rowUpdate (row, index, loading, done) {
        row.position = row.positionIds;
        update(row).then(() => {
          loading();
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
        }, error => {
          done();
          console.log(error);
        });
      },
      searchReset () {
        this.query = {};
        this.beginAddTime = ''
        this.endAddTime = ''
        this.onLoad(this.page);
      },
      // 选中状态变化时
      selectionChange(list) {
        this.allAmount= 0;
        let _idList = [];
        let tempAllMoney = 0;
        list.forEach(item => {
          tempAllMoney+=item.amount;
          _idList.push(item.id);
        });
        tempAllMoney = Number(tempAllMoney);
        this.allAmount =Math.round(tempAllMoney * 100) / 100;
        this.idList = _idList;
      },
      searchChange (params,done) {
        this.page.currentPage=1
        params.beginAddTime = this.beginAddTime
        params.endAddTime = this.endAddTime
        console.log(params)
        this.query = params;
        this.onLoad(this.page, params,done);
      },
      currentChange (currentPage) {
        this.page.currentPage = currentPage;
      },
      sizeChange (pageSize) {
        this.page.pageSize = pageSize;
      },
      refreshChange () {
        this.onLoad(this.page);
      },
      onLoad (page, params = {},done) {
        this.loading = true;
        /*
        * 针对融创项目，提现审核只有买家提交的提现申请，所以，这里不再考虑店铺用户的申请记录了
        *  this.query.uaType = 1; //用户申请记录
        * */
        this.query.uaType = 1; //用户申请记录
        getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
          if(done){
            done();
          }
          this.loading = false;
          const data = res.data;
          this.page.total = data.count;
          this.data = data.data;
        });
      },
      //打开审核抽屉
      //0，未处理 1，审核通过  2，审核拒绝  3，未打款  4，已完成
      getDetail(row){
        this.loadBtn=false
        if(row.status == 0 || row.status == 3){
          this.optionView.group[1].display = true;
        }
        else {
          this.optionView.group[1].display = false;
        }
        if(row.status == 0){
          this.optionView.group[0].column[5].display = false;//审核操作人
          this.optionView.group[0].column[6].display = false;//审核操作时间
          this.optionView.group[0].column[7].display = false;//审核拒绝原因
          this.optionView.group[0].column[8].display = false;//打款状态
          this.optionView.group[0].column[9].display = false;//打款人
          this.optionView.group[0].column[10].display = false;//打款时间
          this.optionView.group[0].column[11].display = false;//实际打款金额
          this.optionView.group[0].column[12].display = false;//打款备注
        }
        else if(row.status == 1){
          this.optionView.group[0].column[5].display = true;//审核操作人
          this.optionView.group[0].column[6].display = true;//审核操作时间
          this.optionView.group[0].column[8].display = true;//打款状态
          this.optionView.group[0].column[7].display = false;//审核拒绝原因
        }
        else if(row.status == 2){
          this.optionView.group[0].column[5].display = true;//审核操作人
          this.optionView.group[0].column[7].display = true;//审核拒绝原因
          this.optionView.group[0].column[8].display = false;//打款状态
          this.optionView.group[0].column[9].display = false;//打款人
          this.optionView.group[0].column[10].display = false;//打款时间
          this.optionView.group[0].column[11].display = false;//实际打款金额
          this.optionView.group[0].column[12].display = false;//打款备注
        }
        else if(row.status == 3){
          this.optionView.group[0].column[5].display = true;//审核操作人
          this.optionView.group[0].column[6].display = true;//审核操作时间
          this.optionView.group[0].column[8].display = true;//打款状态
          this.optionView.group[0].column[7].display = false;//审核拒绝原因
        }
        else if(row.status == 4){
          this.optionView.group[0].column[5].display = true;//审核操作人
          this.optionView.group[0].column[6].display = true;//审核操作时间
          this.optionView.group[0].column[8].display = true;//打款状态
          this.optionView.group[0].column[7].display = false;//审核拒绝原因
          this.optionView.group[0].column[9].display = true;//打款人
          this.optionView.group[0].column[10].display = true;//打款时间
          this.optionView.group[0].column[11].display = true;//实际打款金额
          this.optionView.group[0].column[12].display = true;//打款备注
        }

        //打款状态:0:已打款，1未打款
        if( typeof row.payStatus == 'number' &&  row.payStatus == 1){
          this.optionView.group[0].column[9].display = false;//打款人
          this.optionView.group[0].column[10].display = false;//打款时间
          this.optionView.group[0].column[11].display = false;//实际打款金额
          this.optionView.group[0].column[12].display = false;//打款备注
        }
        else if(typeof row.payStatus == 'number' &&  row.payStatus == 0){
          this.optionView.group[0].column[9].display = true;//打款人
          this.optionView.group[0].column[10].display = true;//打款时间
          this.optionView.group[0].column[11].display = true;//实际打款金额
          this.optionView.group[0].column[12].display = true;//打款备注
        }
        else {
          this.optionView.group[0].column[9].display = false;//打款人
          this.optionView.group[0].column[10].display = false;//打款时间
          this.optionView.group[0].column[11].display = false;//实际打款金额
          this.optionView.group[0].column[12].display = false;//打款备注
        }

        /*
        * 团长类型，为"融创员工"，隐藏掉"提现方式","收款账户"，否则显示
        * '团长身份：1  融创员工，2  带货达人',
        * */
        if(typeof row.groupType == 'number' &&  row.groupType == 1){
          this.optionView.group[0].column[1].display = false;//提现账户
          // this.optionView.group[0].column[3].display = false;//提现渠道
        }
        else {
          this.optionView.group[0].column[1].display = true;//提现账户
          // this.optionView.group[0].column[3].display = true;//提现渠道
        }
        //无论何种情况，隐藏掉提现渠道
        this.optionView.group[0].column[3].display = false;//提现渠道

        getWithDrawRecordDetail(row.id).then(res => {
          if(res.data.code == 200){
            this.obj = res.data.data;
            this.obj.newStatus = res.data.data.status;
            console.log(this.obj)
			if(this.obj.payRemark==''){
				this.obj.payRemark = '无'
			}
			if(this.obj.remark==''){
				this.obj.remark = '无'
			}
            this.dialogTableVisible = true
          }else{
            this.$message({
              message: res.data.message,
              type: 'warning'
            });
            return;
          }
        });
      },
      //审核弹框打开
      commitCheck(id,status,refuseRemark){
        this.loadBtn=true
        if(status == ""){
          this.$message.error("请点击审核选项");
          this.loadBtn=false
          return;
        }
        if(status == 2){
          if(!refuseRemark){
            this.$message({
              type: "error",
              message: "审核拒绝原因不能为空"
            });
            this.loadBtn=false
            return;
          }
          else {
            // var regEn = /[`~!@#$%^&*()_+<>?:"{},.\/;'[\]]/im
            // var  regCn = /[·！#￥（——）：；“”‘、，|《。》？、【】[\]]/im;
            var regEn = /[`@#$%^&*()_+<>{},\/;'[\]]/im;
            var  regCn = /[#￥（——）：；“”‘|《。》？【】[\]]/im;
            if(regEn.test(refuseRemark) || regCn.test(refuseRemark)) {
              this.$message({
                type: "error",
                message: "拒绝不能包含特殊字符"
              });
              this.loadBtn=false
              return false;
            }

            if(refuseRemark.length>100){
              this.$message({
                type: "error",
                message: "原因最多输入100个字符"
              });
              this.loadBtn=false
              return;
            }
          }
        }
        withDrawStatusOthers(id,status,refuseRemark).then(res => {
          if(res.data.code == 200){
            this.dialogTableVisible = false
            this.$message({
              type:'success',
              message:'操作成功!'
            })
            this.onLoad(this.page, this.query);
          }
          else {
            this.$message({
              type: "error",
              message: res.data.message
            });
          }
        });
      },
      //审核弹框关闭
      cancel(newStatus){
        console.log(this.obj);
        this.dialogTableVisible = false
        this.obj.refuseRemark = ''
        this.loadBtn=false
        this.obj.status = newStatus
      },

      //0，已打款 1，未打款
      goPayDetail(row){
        console.log(this.alreadyPayOptionView.group[0].column)
        this.goPayLoadBtn=false
        if(row.payStatus == 0){
          this.alreadyPayOptionView.group[1].display = false;
        }
        else if(row.payStatus == 1){
          this.alreadyPayOptionView.group[1].display = true;
        }
        //0，未处理 1，审核通过  2，审核拒绝  3，未打款  4，已完成
        if(row.status == 4){
          this.alreadyPayOptionView.group[0].column[5].display = true;//打款人
          this.alreadyPayOptionView.group[0].column[6].display = true;//打款时间
          this.alreadyPayOptionView.group[0].column[7].display = true;//打款备注
        }
        else {
          this.alreadyPayOptionView.group[0].column[5].display = false;
          this.alreadyPayOptionView.group[0].column[6].display = false;
          this.alreadyPayOptionView.group[0].column[7].display = false;//打款备注
        }

        if(typeof row.groupType == 'number' &&  row.groupType == 1){
          this.alreadyPayOptionView.group[0].column[1].display = false;//提现账户
          // this.alreadyPayOptionView.group[0].column[3].display = false;//提现渠道
        }
        else {
          this.alreadyPayOptionView.group[0].column[1].display = true;//提现账户
          // this.alreadyPayOptionView.group[0].column[3].display = true;//提现渠道
        }

        //无论何种情况隐藏掉提现渠道
        this.alreadyPayOptionView.group[0].column[3].display = false;//提现渠道

        getWithDrawRecordDetail(row.id).then(res => {
          if(res.data.code == 200){
            this.payObj = res.data.data;
            this.payObj.actualAmount = res.data.data.actualAmount==0?"":res.data.data.actualAmount
            this.payObj.payRemark = res.data.data.payRemark;
            this.payObj.newPayStatus = res.data.data.payStatus;
			if(this.payObj.remark==''){
				this.payObj.remark = '无'
			}
            this.payObj.payStatus = 0;
            console.log(this.payObj)
            this.goPayDialogTableVisible = true
          }else{
            this.$message({
              message: res.data.message,
              type: 'warning'
            });
            return;
          }
        });
      },

      //打款弹框打开
      commitGoPayCheck(id,payStatus,actualAmount,payRemark){
        this.goPayLoadBtn=true
        this.$refs['payCommit'].validate((valid) => {
          if (valid) {
            //提交打款
            withDrawCarryOut(id,payStatus,actualAmount,payRemark).then(res => {
              if(res.data.code == 200){
                this.goPayDialogTableVisible = false
                this.$message({
                  type:'success',
                  message:'操作成功!'
                })
                this.goPayLoadBtn=false
                this.$refs.payCommit.resetForm();
                this.$refs.payCommit.clearValidate();
                this.onLoad(this.page, this.query);
              }
            });
          } else {
            this.goPayLoadBtn=false
            return false;
          }
        });
      },
      //打款弹框关闭
      cancelGoPayCheck(newPayStatus){
        this.goPayDialogTableVisible = false;
        this.goPayLoadBtn=false;
        this.payObj.payStatus = newPayStatus;
        this.payObj.payRemark = ''
        this.payObj.actualAmount = ''
        this.$refs.payCommit.resetForm();
        this.$refs.payCommit.clearValidate();
        this.onLoad(this.page);
      },

      //点击的导出按钮，选择导出方式
      outExcelDialog(){
        this.dialogVisibleOutExcel = true;
      },

      // 仅导出事件
      outExcel(){
        if (this.idList.length>0){


        let token = getToken();
        let groupType = this.query.groupType === undefined ? '' : this.query.groupType;
        let groupName = this.query.groupName === undefined ? '' : this.query.groupName;
        let groupMobile = this.query.groupMobile === undefined ? '' : this.query.groupMobile;
        let status = this.query.status === undefined ? '' : this.query.status;
        let beginAddTime = this.query.beginAddTime === undefined ? '' : this.query.beginAddTime;
        let endAddTime = this.query.endAddTime === undefined ? '' : this.query.endAddTime;
        let idList = this.idList;
        window.location.href =
                '/account/withDrawRecord/outExcel?token=' +
                token +
                '&groupType=' +
                groupType +
                '&groupName=' +
                groupName +
                '&groupMobile=' +
                groupMobile +
                '&status=' +
                status +
                '&beginAddTime=' +
                beginAddTime +
                '&endAddTime=' +
                endAddTime +
                '&idList=' +
                idList;
        }else {
          this.$message.error("至少选择一项数据");
        }
      },
      outAllExcel(){
        let token = getToken();
        let groupType = this.query.groupType === undefined ? '' : this.query.groupType;
        let groupName = this.query.groupName === undefined ? '' : this.query.groupName;
        let groupMobile = this.query.groupMobile === undefined ? '' : this.query.groupMobile;
        let status = this.query.status === undefined ? '' : this.query.status;
        let beginAddTime = this.query.beginAddTime === undefined ? '' : this.query.beginAddTime;
        let endAddTime = this.query.endAddTime === undefined ? '' : this.query.endAddTime;
        window.location.href =
                '/account/withDrawRecord/outExcel?token=' +
                token +
                '&groupType=' +
                groupType +
                '&groupName=' +
                groupName +
                '&groupMobile=' +
                groupMobile +
                '&status=' +
                status +
                '&beginAddTime=' +
                beginAddTime +
                '&endAddTime=' +
                endAddTime ;
      },


      /**
       * 导出，并把状态改为处理中
       * 我这里先把状态改为处理中，然后再导出
       * */
      outExcelChangeStatus(){
        let groupType = this.query.groupType === undefined ? '' : this.query.groupType;
        let groupName = this.query.groupName === undefined ? '' : this.query.groupName;
        let groupMobile = this.query.groupMobile === undefined ? '' : this.query.groupMobile;
        let status = this.query.status === undefined ? '' : this.query.status;
        let beginAddTime = this.query.beginAddTime === undefined ? '' : this.query.beginAddTime;
        let endAddTime = this.query.endAddTime === undefined ? '' : this.query.endAddTime;
        let data={
          groupType:groupType,
          groupName:groupName,
          groupMobile:groupMobile,
          status:status,
          beginAddTime:beginAddTime,
          endAddTime:endAddTime,
          idList:this.idList
        };
        //更新状态为处理中
        selectAndUpdate(data).then(res => {
          if(res.data.code == 200){
            if(res.data.data){
              this.outExcel();
              this.onLoad(this.page);
            }
          }
        });
      },
      handleSuccess(val){
        if(val.code ==200){
          this.$message.success('上传成功!');
          this.onLoad(this.page);
        }
        else {
          this.$message.error(val.message);
        }
      },
    }
  };
</script>

<style>
  .btnRow {
    position: relative;
    bottom: 51px;
    left: 10px;
  }
  .allAmount{
    margin-left: 5px;
  }
  .upload-tip {
    line-height: 20px;
    width: auto;
    margin: 0 0 0 10px;
    word-break: keep-all;
  }
</style>
